<template>
    <ListPage ref="page" :query="query" :api="getCustomerList">

        <template #search="{ page, hiddenColumns }">
            <PageSearch ref="search" :query="query" :page="page" has-box @search="() => ($refs.page as any).getData()">
                <template #auth>

                </template>
                <template #input="{ }">
                    <SearchInput v-model="query.keyword" placeholder="客户名称/店铺名称/业务名称"  :data="query"
                        :hidden-columns="(hiddenColumns as any)" @trigger="(e) => ($refs.search as any).trigger(e)"
                        @search="() => ($refs.page as any).getData()"
                        @change-column="(prop) => ($refs.page as any).changeColumn(prop)"></SearchInput>
                </template>
            </PageSearch>
        </template>

        <template #table="{ data, hiddenColumns }">
            <ListTable :data="data" :hidden-columns="(hiddenColumns as any)" @edit-yw="onEditShopBusiness">
            </ListTable>
        </template>
    </ListPage>
</template>

<script setup lang="ts">

import { ref, reactive } from 'vue'
import ListPage from '@/components/list-page/ListPage.vue'
import { getCustomerList } from '../api'
import ListTable from './ListTable.vue'
import PageSearch from '@/components/list-page/PageSearch.vue'
import SearchInput from '@/components/list-page/SearchInput.vue'
import { shopBusinessManageDialog } from '../dialog/shopBusinessManageDialog'

const page = ref()

const query = reactive({
    keyword: '',
    customerName: ''
})

const onEditShopBusiness = async (row) => {
    console.log(row);
    await shopBusinessManageDialog.open({ row });
    // 刷新数据
    page.value && page.value.getData();
}

</script>